using System.Buffers;

namespace eNets.IO.Buf;

public static class BufferProvider
{
    public static IBuffer<T> CreateUnsafeBuffer<T>()
    {
        return CreateUnsafeBuffer(BufferOptions<T>.Default);
    }

    public static IBuffer<T> CreateUnsafeBuffer<T>(MemoryPool<T> memoryPool)
    {
        return CreateUnsafeBuffer(new BufferOptions<T>(pool: memoryPool));
    }

    public static IBuffer<T> CreateUnsafeBuffer<T>(BufferOptions<T> options)
    {
        return new Buffer<T>(options);
    }
    
    
    public static IBuffer<T> CreateSafeBuffer<T>()
    {
        return CreateSafeBuffer(BufferOptions<T>.Default);
    }

    public static IBuffer<T> CreateSafeBuffer<T>(MemoryPool<T> memoryPool)
    {
        return CreateSafeBuffer(new BufferOptions<T>(pool: memoryPool));
    }

    public static IBuffer<T> CreateSafeBuffer<T>(BufferOptions<T> options)
    {
        return new SafeBuffer<T>(options);
    }
}